import axios from "axios"
import { Message } from 'element-ui';
// let loading;
// 使用create创建axios实例
const Service = axios.create({
    timeout: 8000,
    baseURL: 'http://114.116.112.52:8080/',
    headers: {
        "content-type": "application/json;charset=utf-8",
    }
});

// // 请求拦截
// Service.interceptors.request.use(confirm => {
//     // loading = Loading.service(options);
// })

// 响应拦截
Service.interceptors.response.use(config => {
    Message({
        message: '操作成功',
        type: 'success',
        duration: 2000,
    })
    return config;
    // loading.close();
},
error => {
    // loading.close();
    Message({
        message: '服务器错误',
        type: 'error',
        duration: 2000,
    })
});

export const post = config => {
    return Service({
        ...config,
        method: 'post',
        data: config.data,
    })
}

export const get = config => {
    return Service({
        ...config,
        method: 'get',
        params: config.data,
    })
}